package org.example.IO;

import java.io.*;

/**
 * @className: Demo10
 * @author: 芃
 * @description: 文件的写入（字节流）
 * @date: 2024/5/6 18:34
 */
public class Demo10 {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("D:\\My_Code\\Java_Code\\EE_And_System_New\\Test\\src\\main\\java\\org\\example\\IO\\test2.txt", true)){
            outputStream.write("hello world".getBytes());
            //writer写入文件，默认情况下会覆盖原文件内容，如果不想清空，需要在writer构造方法中传入true参数,表示追加写入
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
